﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Caihongtu
{
    class Log
    {
        /**//// <summary>
            /// 写入日志文件
            /// </summary>
            /// <param name="input"></param>
        public void WriteLogFile(string input)
        {
            /**/
            ///指定日志文件的目录
            //string strNow = DateTime.Now.ToString("yyyyMM");
            if (Directory.Exists("E://Caihongtu") == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory("E://Caihongtu");
            }
            string fname = "E:\\Caihongtu\\order" ;
            Console.WriteLine(fname);

            FileInfo finfo = new FileInfo(fname);

            if (!finfo.Exists)
            {
                FileStream fs;
                fs = File.Create(fname);
                fs.Close();
                finfo = new FileInfo(fname);
            }

            using (FileStream fs = finfo.OpenWrite())
            {
                StreamWriter w = new StreamWriter(fs);
                w.BaseStream.Seek(0, SeekOrigin.End);
                w.Write(input + "\r");
                w.Flush();
                w.Close();
            }
        }
        public void WriteLogFileDetail(string input)
        {
            /**/
            ///指定日志文件的目录
            //string fname = Directory.GetCurrentDirectory() + "\\LogFile.txt";
            //string strNow = DateTime.Now.ToString("yyyyMM");
            if (Directory.Exists("E://Caihongtu") == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory("E://Caihongtu");
            }
            string fname = "E:\\Caihongtu\\"  + "order.Detail";
            Console.WriteLine(fname);

            FileInfo finfo = new FileInfo(fname);

            if (!finfo.Exists)
            {
                FileStream fs;
                fs = File.Create(fname);
                fs.Close();
                finfo = new FileInfo(fname);
            }

            using (FileStream fs = finfo.OpenWrite())
            {
                StreamWriter w = new StreamWriter(fs);
                w.BaseStream.Seek(0, SeekOrigin.End);
                w.Write(input + "\r");
                w.Flush();
                w.Close();
            }
        }
    }
}
